Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sqlite3Worker1Promiser type declarations #54

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tomayac
Copy link
Collaborator

@tomayac tomayac commented Nov 27, 2023

Fixes #53

@jbaiter
Copy link
Contributor

jbaiter commented Nov 27, 2023

This is going to need lots of overloads:

A Promiser object is a function with two call signatures:

   ( messageType, messageArguments ) is equivalent to:
   ( {type: messageType, args: type-specific value} )

where the type is always a string and the args value is message-type specific. It always returns a Promise object which resolves to an object:

{
  type: messageType,
  result: type-specific result value,
  ... possibly other metadata ...
}

https://sqlite.org/wasm/doc/tip/api-worker1.md#promiser

@tomayac tomayac changed the title Start work on sqlite3Worker1Promiser type declarations Add sqlite3Worker1Promiser type declarations Jan 9, 2024
@GabrielDelepine
Copy link

Hi, I wanted to let you know that I am currently working on writing the types. I expect to be in a position to share my work with you in the next few days.

@NoelDeMartin
Copy link

Hey, I just added some partial types to a project recently. They are not comprehensive by any means, but maybe they can serve to get started or to get some ideas: https://github.com/moodlehq/moodleapp/blob/main/src/types/sqlite-wasm.d.ts

@GabrielDelepine
Copy link

Hi,
Still working on it, fine-tuning messageId to unlock its full potential

@sgbeal
Copy link
Collaborator

sgbeal commented Feb 26, 2024

Note that the messageId is an internal-use property used for dispatching messages between the worker and callbacks. It is hypothetically conceivable for clients to tinker with but no actual use for that comes to mind. FWIW, IMO messageId should be flagged as an opaque type of no interest to clients.

@tomayac tomayac mentioned this pull request May 21, 2024
@sameoldlab
Copy link

Hi, I made a PR to merge with this adding most of the Sqlite3Worker1Promiser related types #76. Still have a few things left to do mainly with PromiserMethods, but would appreciate a second look from anyone interested

@sameoldlab
Copy link

Also copying over my progress comment avoid splitting overall progress discussion:

Progress:

  • Mostly done with Sqlite3Worker1PromiserConfig. Not sure what goes in for the args of generateMessageId
  • Need clearer documentation for Promiser Method open's filename and vfs
  • exec needs to add a full list of arguments, js eqivalent for sql VALUE value used in row and bind
  • There is additional metadata returned by Promiser. Described as "// possibly other metadata ..." on sqlite docs. Not sure how stable these are / if they should be documented here.
  • Need to add type for Promiser response error stack trace array

As the methods are very similar to worker1, I'm hoping I can reduce what is specified here and reuse the existing types where possible.

Add types for `Sqlite3Worker1Promiser`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing typing for sqlite3Worker1Promiser
6 participants